# 业务层，实现登录、注册
import orm
def login():
    path = r'username.json'
    tag = 0
    name = input('请输入用户名：')
    pwd = input('请输入密码：')
    user_list= orm.read_data(path)
    for user in user_list:
        if name==user['username'] and pwd==user['password']:
            tag =1
            break
    return tag

def register():
    path= r'username.json'
    name=input('请输入注册的用户名：')
    pwd=input('请输入注册的密码：')
    new_user={'username':name,'password':pwd}
    user_list= orm.read_data(path)
    user_list.append(new_user)
    orm.write_data(user_list, path)
    return user_list

if __name__ == '__main__':
    #测试一下login()
    # print(assert())
    #测试一下register()
    print(register())